package day240131;

public class Bubble {
    public static void main(String[] args) {
        int[] arr = new int[]{28, 5, 11, 9, 2};

        System.out.println("排序之前：");

        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();

        int t;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4-i; j++) {
                if (arr[j] > arr[j+1]){
                    t = arr[j];
                    arr[j] = arr[j+1];
                    arr[j+1] = t;
                }
            }
        }

        System.out.println("排序之后：");
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }

    }
}
